﻿Public Class FormEditTask
    Public Property TaskDate As Date
    Public Property TaskDescription As String
    Public Property DueAt As DateTime ' 新增：完整提醒时间

    Private Sub FormEditTask_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' 日期
        If TaskDate = Date.MinValue Then
            dtpDate.Value = Date.Today
        Else
            dtpDate.Value = TaskDate
        End If

        ' 描述
        txtDescription.Text = TaskDescription

        ' 时间（仅时分）
        If DueAt = Date.MinValue Then
            dtpTime.Value = Date.Today.AddHours(9) ' 默认09:00
        Else
            dtpTime.Value = Date.Today.Add(DueAt.TimeOfDay)
        End If
    End Sub

    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
        Dim desc = txtDescription.Text.Trim()
        If String.IsNullOrWhiteSpace(desc) Then
            MessageBox.Show("请输入待办内容！")
            Return
        End If

        TaskDate = dtpDate.Value.Date
        TaskDescription = desc

        ' 合成完整提醒时间：日期 + 时分
        Dim onlyTime As TimeSpan = dtpTime.Value.TimeOfDay
        DueAt = TaskDate.Add(onlyTime)

        Me.DialogResult = DialogResult.OK
    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        Me.DialogResult = DialogResult.Cancel
    End Sub
End Class
